home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / admin-v1.000 / admin-v1 / texmgr < prev    next >
Text File  |  1995-05-20  |  6KB  |  207 lines

  1. #!/bin/sh
  2. #
  3. # Copyright Romolo Manfredini, Parma, Italy IT
  4. #
  5. # Credits to Patrick Volkerding, Moorhead, Minnesota USA
  6. # as this script was strongly inspired by pkgtool.
  7. # All rights reserved.
  8. #
  9. # Redistribution and use of this script, with or without modification, is 
  10. # permitted provided that the following conditions are met:
  11. #
  12. # 1. Redistributions of this script must retain the above copyright
  13. #    notice, this list of conditions and the following disclaimer.
  14. #
  15. #  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  16. #  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
  17. #  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
  18. #  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
  19. #  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  20. #  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  21. #  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
  22. #  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
  23. #  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
  24. #  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. #
  26.  
  27. # Mon Jul 25 13:50:48 MET DST 1994
  28. # Tues Jan 24 14:00 CST 1995
  29. # Modified by Emmett Sauer for inclusion into Linux Business Systems
  30. #
  31. # start of User configurable section:
  32. TVERSION="Linux Business Systems V1.1                    `date`"
  33. EDITOR=joe
  34.  
  35. # end of User configurable section:
  36.  
  37. show_help() {
  38.    dialog --title "TeXmgr Help" --infobox \
  39. "\nThese program have the aim to help you in handling TeX files \n\
  40. expecially for cleaning directories and printing \n\n   \
  41. Usage: texmgr [nomefile]." 7 76
  42. }
  43.  
  44. delete_tex_files() {
  45. rm *.log *.toc *.tp *.tps *.vr *.vrs *.ky *.kys *.aux *.cp *.cps *.pg *.pgs *.fn *.fns 2> /dev/null >/dev/null
  46.  }
  47.  
  48. delete_all_tex_files() {
  49. rm *.dvi *.ps *.log *.toc *.tp *.tps *.vr *.vrs *.ky *.kys *.aux *.cp *.cps *.pg *.pgs *.fn *.fns 2> /dev/null >/dev/null
  50.  }
  51.  
  52. # Here, we read the list of arguments passed to the pkgtool script.
  53. if [ $# -gt 0 ]; then # there are arguments to the command
  54.  while [ $# -gt 0 ]; do
  55.   case "$1" in
  56.   "--help")
  57.   show_help;
  58.   sleep 10;
  59.   exit
  60.   "-?"
  61.   show_help;
  62.   sleep 10;
  63.   exit
  64.   esac
  65.   if [ -t $1 ]; then
  66.    TEXFILE=`basename $1|sed -e '/.tex/s///'`
  67.    WORK_DIR=`dirname $1`
  68.    cd $WORK_DIR
  69.    break
  70.   else
  71.     show_help;
  72.     sleep 5
  73.     break;
  74.   fi
  75.  done
  76. fi    # there were no arguments, so we'll get the needed information from the
  77.       # user and then go on.
  78. WORK_DIR=`pwd`
  79. while [ 0 ]; do
  80. if [ "$TEXFILE" = "" ]; then
  81.  dialog --title "TeX Manager Version 1.0d" \
  82. --backtitle " $TVERSION" \
  83. --menu "\nWelcome to TeXmgr V1.0d.\n\
  84. \nWhich option would you like?\n\
  85. \nCurrent directory is: $WORK_DIR \n" 19 74 6 \
  86. "File" "Choose a .tex file to process in the current dir" \
  87. "Clean" "Remove .log .aux etc files but leave .dvi and .ps" \
  88. "VeryClean" "Remove also .dvi and .ps" \
  89. "DirChange" "Change working directory" \
  90. "NewFile" "Start with a new file" \
  91. "Exit" "Exit TeXmgr" 2> /tmp/reply$$
  92.   if [ $? = 1 -o $? = 255 ]; then
  93.    rm -f /tmp/reply$$
  94.    reset
  95.    exit  
  96.   fi
  97.   REPLY="`cat /tmp/reply$$`"
  98.   rm -f /tmp/reply$$
  99.   if [ "$REPLY" = "Exit" ]; then
  100.    reset
  101.    exit
  102.   elif [ "$REPLY" = "File" ]; then
  103.    dialog --title "SCANNING" --infobox "Please wait while \
  104. TeXmgr looks for TeX files present in the current directory." 7 40
  105.    echo 'dialog --menu "Please select the file you wish to process." 15 55 8 \' >/tmp/viewscr$$
  106.    if [ "`ls *.tex 2>/dev/null`" = "" ]; then
  107.        dialog --title "NO FILE FOUND" \
  108. --msgbox "No *.tex file found in the  \
  109. current directory, please change \
  110. directory and then try again." 10 50
  111.    else 
  112.    ls *.tex|sed -e '/.tex/s///'|sed -e 's/.*/"&" "" \\/' >> /tmp/viewscr$$
  113.    echo "2> /tmp/return\$\$" >> /tmp/viewscr$$
  114.    while [ 0 ]; do
  115.     source /tmp/viewscr$$
  116.     if [ ! "`cat /tmp/return$$`" = "" ]; then
  117.      TEXFILE=`cat /tmp/return$$`
  118.      break
  119.     else
  120.      break 
  121.     fi
  122.    done
  123.    rm -f /tmp/return$$ /tmp/viewscr$$ /tmp/tmpmsg
  124.   fi
  125.   elif [ "$REPLY" = "NewFile" ]; then
  126. dialog --title "Starting a new TeX file" --inputbox "Please enter the new\
  127.  file name:" 10 50 2>/tmp/newfile$$
  128.    if [ $? = 1 ]; then
  129.     rm -f /tmp/newfile$$
  130.     reset
  131.    else
  132.     STRING="`cat /tmp/newfile$$`"
  133.     rm -f /tmp/newfile$$
  134.     if [ "$STRING" != "" ]; then
  135.      WORK_DIR=`dirname $STRING`
  136.      TEXFILE=`basename $STRING|sed -e '/.tex/s///'`
  137.      cd $WORK_DIR
  138.      WORK_DIR=`pwd`
  139.     fi
  140.    fi
  141.   elif [ "$REPLY" = "Clean" ]; then
  142.   delete_tex_files;
  143.   elif [ "$REPLY" = "VeryClean" ]; then
  144.   delete_all_tex_files;
  145.   elif [ "$REPLY" = "DirChange" ]; then
  146. dialog --title "SELECT SOURCE DIRECTORY" --inputbox "Please enter the new\
  147.  working directory:" 10 50 2>/tmp/wrkdir$$
  148.    if [ $? = 1 ]; then
  149.     rm -f /tmp/wrkdir$$ 
  150.     reset
  151.     exit
  152.    fi
  153.    WORK_DIR="`cat /tmp/wrkdir$$`"
  154.    rm -f /tmp/wrkdir$$
  155.    if [ ! -d $WORK_DIR ]; then
  156.     dialog --title "DIRECTORY NOT FOUND" \
  157. --msgbox "The directory you have selected \
  158. does not seem to exist. Please check the \
  159. directory and then try again." 10 50
  160.     reset
  161.    else
  162.     cd $WORK_DIR
  163.     WORK_DIR=`pwd`
  164.    fi;
  165.   fi;
  166.  else
  167.  dialog --title "TeX Manager Version 1.0d" \
  168. --backtitle " $TVERSION" \
  169. --menu "\nWelcome to TeXmgr V1.0d.\n \
  170. \nWhich option would you like?\n \
  171. \nCurrent directory is: $WORK_DIR \n" 19 74 6 \
  172. "TeX" "From $TEXFILE.tex make $TEXFILE.dvi using TeX." \
  173. "LaTeX" "From $TEXFILE.tex make $TEXFILE.dvi using LaTeX." \
  174. "Dvips" "From $TEXFILE.dvi make $TEXFILE.ps." \
  175. "Print" "Print $TEXFILE.ps using gsprint." \
  176. "Edit" "Edit $TEXFILE.tex using $EDITOR." \
  177. "Menu" "Goto TOP level menu" 2> /tmp/reply$$
  178.   if [ $? = 1 -o $? = 255 ]; then
  179.    rm -f /tmp/reply$$
  180.    echo Menu >/tmp/reply$$
  181.   fi
  182.   REPLY="`cat /tmp/reply$$`"   
  183.   rm /tmp/reply$$
  184.   if [ "$REPLY" = "TeX" ]; then
  185.    reset
  186.    tex $TEXFILE.tex
  187.    sleep 2
  188.   elif [ "$REPLY" = "LaTeX" ]; then
  189.    reset
  190.    latex $TEXFILE.tex
  191.    sleep 2
  192.   elif [ "$REPLY" = "Dvips" ]; then
  193.    reset
  194.    dvips -o$TEXFILE.ps $TEXFILE.dvi
  195.    sleep 2
  196.   elif [ "$REPLY" = "Print" ]; then
  197.    gsprint $TEXFILE.ps
  198.   elif [ "$REPLY" = "Edit" ]; then
  199.    $EDITOR $TEXFILE.tex
  200.   elif [ "$REPLY" = "Menu" ]; then
  201.    TEXFILE=""
  202.   fi
  203.  fi
  204. done
  205.  
  206.   
  207.